<?php

class Blog
{
  static public function slugify($text)
  {   
 
    // transliterate
    $healthy = array("á","é","í","ó","ú","%20", " ","'",'"',"“","”",'ñ','?','¿');
    $yummy   = array("a","e","i","o","u", "-", "-","-","","","",'n', '', '');
    $text = str_replace($healthy, $yummy, $text);
  
    // replace all non letters or digits by -
    $text = preg_replace('/\W+/', '-', $text);
    
    // trim and lowercase
    $text = strtolower(trim($text, '-'));
    
    // remove unwanted characters
    $text = preg_replace('#[^-\w]+#', '', $text);
 
    if (empty($text))
    {
        return 'n-a';
    }
    
    return $text;
  }
}
?>
